<template>
  <div class="static-parameter-group">
    <div class="group-header">
      <h3>{{ group.groupName }}</h3>
      <div class="group-info">
        <el-tag size="mini" type="info">静态参数组</el-tag>
        <span class="param-count">{{ group.paramItems.length }} 个参数</span>
      </div>
    </div>
    
    <div class="parameters-grid">
      <parameter-field
        v-for="param in sortedParams"
        :key="param.paramId"
        :param="param"
        :value="formData[param.paramCode]"
        @change="handleFieldChange"
      />
    </div>
  </div>
</template>

<script>
import ParameterField from './ParameterField.vue'

export default {
  name: 'StaticParameterGroup',
  components: {
    ParameterField
  },
  props: {
    group: {
      type: Object,
      required: true
    },
    formData: {
      type: Object,
      required: true
    }
  },
  computed: {
    sortedParams() {
      return [...this.group.paramItems].sort((a, b) => a.sortOrder - b.sortOrder)
    }
  },
  methods: {
    handleFieldChange({ paramCode, value }) {
      this.$emit('param-change', { paramCode, value })
    }
  }
}
</script>

<style scoped>
.static-parameter-group {
  padding: 20px 30px;
  background: white;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e6e8eb;
}

.group-header h3 {
  margin: 0;
  color: #303133;
  font-size: 16px;
}

.group-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.param-count {
  color: #909399;
  font-size: 12px;
}

.parameters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
</style>